/**
 * Created by lvlq on 16/2/26.
 */
var index = function (req, res) {
    var Test = M("index.test");
    Test.sync();
    res.json({a: 1});
};

var initActivelist = function (req, res) {
    var activeList = M("index.activeList");
    activeList.sync({
        force: true
    }).then(function () {
        return activeList.create({
            name: "幸运有你大转盘"
        })
    }).then(function () {
        return activeList.create({
            name: "拼颜值 100%赢豪礼"
        });
    }).then(function () {
        res.json({a: 1});
    });
};


var initPrizelist = function (req, res) {
    var PrizeList = M("index.prizeList");
    PrizeList.sync({
        force: true
    }).then(function () {
        return PrizeList.create({
            aid: 1,
            name: "200元京东电子卡",
            num: 10,
            has_num: 10,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 1,
            name: "100元话费充值卡",
            num: 20,
            has_num: 20,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 1,
            name: "壳牌劲霸R5E 4L润滑油",
            num: 20,
            has_num: 20,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 2,
            name: "乐视TV4K超清智能平板电视 50寸",
            num: 2,
            has_num: 2,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 2,
            name: "IPhone 6Plus手机",
            num: 3,
            has_num: 3,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 2,
            name: "200元京东电子卡",
            num: 10,
            has_num: 10,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 2,
            name: "100元话费充值卡 ",
            num: 20,
            has_num: 10,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 2,
            name: "20元话费充值卡",
            num: 50,
            has_num: 50,
            chance: 0
        })
    }).then(function () {
        return PrizeList.create({
            aid: 2,
            name: "10元话费充值卡",
            num: 999999999,
            has_num: 999999999,
            chance: 10000
        })
    }).then(function () {
        res.json({
            a: 1
        });
    });
};

var initUserlist = function (req, res) {
    var UserList = M("index.userList");
    UserList.sync({
        force: true
    }).then(function () {
        res.json({a: 1});
    })
};

var initImagelist = function (req, res) {
    var ImageList = M("index.imageList");
    ImageList.sync({
        force: true
    }).then(function () {
        res.json({a: 1});
    });
};

var initWsdl = function (req, res) {
    var Wsdl = M("index.wsdl");
    Wsdl.sync({
        force: true
    }).then(function () {
        res.json({a: 1});
    });
};

module.exports = {
    index: index,
    initActivelist: initActivelist,
    initPrizelist: initPrizelist,
    initUserlist: initUserlist,
    initImagelist: initImagelist,
    initWsdl:initWsdl
};